import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/getParameter")
public class QueryStringServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
          resp.setContentType("text/html; charset=utf8") ;

        //   QueryString 要求格式 username=xxx&password=xxxx;
        // 规定好格式, 这里的Query String 就相当于一个Map<String,String> 格式的数据 ,
        // getParameter 就相当于在查询 Map
         String username = req.getParameter("username") ;
         String password = req.getParameter("password");
         //然后,拿到这个参数数据,就可以针对数据进行处理 ;
        System.out.println("name:" + username + " password:"+password);
        resp.getWriter().write("name:" + username + " password:"+password) ;
    }
}
